﻿// -----------------------------------------------------------------------
// <copyright file="UserInterface.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace DataStructures___Exc1
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class UserInterface
    {
        public static int[] GetDataFromFile(string i_fileName,out int i_desiredNumber,out int i_size)
        {
            string stringNumber = "";
            char currentChar;
            int counter = 0;

            System.Console.WriteLine("Please enter file name: ");
            System.IO.StreamReader file = new System.IO.StreamReader(i_fileName);

            i_desiredNumber = int.Parse(file.ReadLine());
            i_size = int.Parse(file.ReadLine());
            int[] numbersArray = new int[i_size];

            while (!(file.EndOfStream))
            {
                currentChar = (char)file.Read();
                while( (currentChar >= '0' && currentChar <= '9') || currentChar == '-')
                {
                    stringNumber += char.ToString(currentChar);
                    currentChar = (char)file.Read();
                }
                if (stringNumber.Length > 0)
                {
                    numbersArray[counter++] = int.Parse(stringNumber);
                }
                stringNumber = "";
            }

            return numbersArray;
        }
    }
}
